package cn.edu.zafu.bigdata.x.wupeng.g;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * 代码并没有排序。
 */
public class SortThread extends Thread {
    private PrintWriter out = null;
    private BufferedReader in =null;

    public SortThread(PrintWriter out, BufferedReader in) {
        this.out = out;
        this.in = in;
    }

    public void run() {
        if(out!=null && in!=null){
            try {
                String input;
                while ((input = in.readLine())!=null){
                    out.println(reverseItem(input));
                    out.flush();
                }
                out.close();
            }
            catch (IOException e){
                throw new RuntimeException(e);
            }
        }
    }
    private String reverseItem(String item){
        int i,len = item.length();
        StringBuffer sb = new StringBuffer(len);
        for(i=len-1;i>=0;i--)
            sb.append(item.charAt(i));
        return sb.reverse().toString();
    }
}
